// 二分查找， 需要注意判断边界， 当left==right 时，结束
let solution =  function (isBadVersion) {
    return function(n) {
        let left = 0;
        let right = n;
        while (left < right) {
            let mid = left + Math.floor((right - left)/2);
            if (isBadVersion(n)) {
                right = mid;
            }
            else {
                left = mid + 1;
            }
        }
        return left;
    }
}